package com.kh.samr.service.impl;

import com.kh.samr.entity.DishonestyParam;
import com.kh.samr.repository.IDishonestyParamRepository;
import com.kh.samr.service.IDishonestyParamService;
import com.kh.samr.utils.ResultUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.transaction.Transactional;

/**
 * @author Harry
 * @date 2021/4/12
 */
@Transactional
@Service
public class DishonestyParamServiceImpl implements IDishonestyParamService {

	private static final Logger log = LoggerFactory.getLogger(DishonestyServiceImpl.class);

	@Resource
	private IDishonestyParamRepository dishonestyParamRepository;

	@Override
	public ResultUtil<String> save(DishonestyParam dishonestyParam) {
		log.info("方法名称：save;参数：" + dishonestyParam.toString());
		boolean b = this.dishonestyParamRepository.existsById(dishonestyParam.getUniformSocialCreditCode());
		ResultUtil<String> resultUtil = new ResultUtil<>();
		if (!b) {
			this.dishonestyParamRepository.save(dishonestyParam);
			resultUtil.setErrcode(0);
			resultUtil.setErrmsg("保存成功！");
			log.info("方法名称：save;返回值：" + resultUtil);
		}
		return resultUtil;
	}
}
